#pragma once

#include "DataManage.h"
#include "cocos2d.h"
#include "cocos-ext.h"

USING_NS_CC_EXT;
using namespace cocos2d;

class ScoreCell : public TableViewCell
{
	Sprite* m_pCellBase = nullptr;
	Sprite* m_pIconSprite = nullptr;
	Label* m_pDataLabel = nullptr;
	Label* m_pRankLabel = nullptr;
	Label* m_pMoneyLabel = nullptr;

protected:
	virtual bool init();
public:
	void updateContent(int cellID);

	CREATE_FUNC(ScoreCell);
};

class ScoreTable : public Node, public TableViewDataSource
{
	TableView* m_pTableView;

protected:
	virtual bool init();
	void updateContent();

public:
	virtual Size cellSizeForTable(TableView* pTable);
	virtual TableViewCell* tableCellAtIndex(TableView* pTable, ssize_t idx);
	virtual ssize_t numberOfCellsInTableView(TableView* pTable);

	CREATE_FUNC(ScoreTable);
};


class ScoreBoard : public Layer
{
public:
	enum
	{
		GAME_SCORE = 0,
		HISTORY_SCORE = 1
	};

	static ScoreBoard* create(int nType);

private:

	bool init(int nType);

	bool gameScoreInit();
	bool historyScoreInit();
	virtual bool initCurrentGameTable(Size innerSize);

	Node* m_pCurrentGameTobale = nullptr;

	bool onTouchBegan(Touch *touch, Event *event) override;
	void onCloseButtonClick();
	void onExitButtonClick();
};

